<script setup>
import {getCurrentInstance, onMounted, ref} from "vue";
import eventBus  from '../../event/eventBus.js';
const NAME = '归位';


let activated = ref(false);
const { appContext } = getCurrentInstance();
let global = appContext.config.globalProperties;

onMounted(() => {
  eventBus.on('mapToolBarClick', (data) => {
    if(data == NAME){
      activated.value = true;

      global.$viewer.camera.flyTo({
        duration:0.5,
        destination: Cesium.Cartesian3.fromDegrees(
            window.mapPosition.lon,
            window.mapPosition.lat,
            window.mapPosition.height
        ), //设置位置
        orientation: {
          heading: Cesium.Math.toRadians(window.mapPosition.heading),
          pitch: Cesium.Math.toRadians(window.mapPosition.pitch),
          roll: 0,
        },
      });
    }else{
      activated.value = false;
    }
  });
});
</script>

<template >
  <div v-if="activated"></div>
</template>